#ifndef POOL_H_INCLUDED
#define POOL_H_INCLUDED
#include "config.h"
#include <mysql++/mysql++.h>
using namespace std;
using namespace mysqlpp;
class Pool : public ConnectionPool {
public:
	static Pool* Get();
    
    virtual Connection* create() {
        return new Connection(db.c_str(), server.c_str(), user.c_str(), password.c_str(), port);
    }
    virtual void destroy(Connection* con) {
        delete con;
    }
	virtual Connection* grab() {
		return ConnectionPool::grab();
	}
    virtual unsigned int max_idle_time() {
        return MAX_IDLE_TIME;
    }
    ~Pool() {
        clear();
    }
private:
	static Pool* instance;
//	Pool(const char* _db, const char* _server, const char* _user,
//                        const char* _password, unsigned int _port);
	Pool();
	Pool(const Pool&);
	Pool& operator=(const Pool&);
    string db, server, user, password;
    unsigned int port;
};

#endif //POOL_H_INCLUDED
